package com.singulee.carschool.service.serviceImpl;

import com.singulee.carschool.mapper.UserMapper;
import com.singulee.carschool.pojo.User;
import com.singulee.carschool.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public User findByUsername(String username) {
        return userMapper.findOneByUsername(username);
    }
    @Override
    public boolean updatePassword(String phone, String password) {
        User u = new User();
        u.setPassword(password);
        u.setUsername(phone);
        u.setStatus(1);
        return userMapper.updatePassword(u) > 0;
    }
    @Override
    public void insert(User user) {
        userMapper.insert(user);
    }
    @Override
    public boolean update(User user) {
        return userMapper.update(user) > 0;
    }
}
